package com.itheima.web;

import com.itheima.dto.RoleDto;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.service.RoleService;
import com.itheima.service.RoleUserService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/role")
public class RoleController {
    @Reference
    private RoleService roleService;

    @Reference
    private RoleUserService roleUserService;

    @PostMapping("/addRole")
    public Result addRole(@RequestBody RoleDto roleDto){
            return new Result(roleService.addRole(roleDto));
    }


    @GetMapping("/findAll")
    public Result findAll(){
        return new Result(roleService.findAll());
    }

    @GetMapping("/delete/{id}")
    public Result delete(@PathVariable Long id){
        return new Result(roleService.delete(id));
    }


    @PostMapping("/findRole")
    public Result findRole(@RequestBody QueryPageBean queryPageBean){
        return new Result(roleService.findRole(queryPageBean));
    }

    @GetMapping("/findUsers/{id}")
    public Result findUsers(@PathVariable("id") Long id){
        return new Result(roleUserService);
    }





}
